package Frame.screen;

import FCRendering.FCRConstants;
import FCRendering.FCRMaster;
import FCRendering.ImageUtil;

import java.awt.*;
import java.util.Date;
import java.util.HashMap;
import java.util.Set;
import java.util.Timer;

import static FCRendering.FCRMaster.*;

public class DefaultLoadingResScreen extends IScreen {
    @Override
    public void dispatchPaintComponent(Graphics g, FCRMaster fcrMaster) {
        g.setColor(Color.black);
        g.fillRect(0, 0, fcrMaster.getWidth(), fcrMaster.getHeight());
        if (fcv.getLoadNum() < 8)
            g.drawImage(ImageUtil.getImage("loadingpng1"), (int) ((fcrMaster.getWidth() - 104 * fcv.getProportion()) / 2),
                    (int) ((fcrMaster.getHeight() - 48 * fcv.getProportion()) / 2), (int) (104 * fcv.getProportion()),
                    (int) (48 * fcv.getProportion()), this);
        else
            g.drawImage(ImageUtil.getImage("loadingpng2"), (int) ((fcrMaster.getWidth() - 104 * fcv.getProportion()) / 2),
                    (int) ((fcrMaster.getHeight() - 48 * fcv.getProportion()) / 2), (int) (104 * fcv.getProportion()),
                    (int) (48 * fcv.getProportion()), this);
        g.setColor(Color.white);
        g.setFont(new Font(FCRConstants.FONT_BLACK, 0, (int) (30 * fcv.getProportion())));
        /**
         * 用以统计数据加载数量
         */
//				System.out.println("---------------------------------");
//				System.out.println("方块:"+blockLib.getBlockNum());
//				System.out.println("地图:"+mapLib.getMapNum());
//				System.out.println("事件:"+eventLib.getEventNum());
//				System.out.println("动作:"+actionLib.getActionNum());
//				System.out.println("怪物:"+monLib.getMonsterNewID());
//				System.out.println("动画:"+animationLib.getAnimationNum());
//				System.out.println("物品:"+itemLib.getItemNewID());
//				System.out.println("剧情:"+plotLib.getPlotNum());
//				System.out.println("坦克:"+tankLib.getNewTankID());
//				System.out.println("总数:"+(blockLib.getBlockNum() + mapLib.getMapNum() + eventLib.getEventNum()
//							+ actionLib.getActionNum() + monLib.getMonsterNewID() + animationLib.getAnimationNum()
//							+ itemLib.getItemNewID() + plotLib.getPlotNum() + tankLib.getNewTankID()));

        fcv.setLoadFileNum((int) (100*(blockLib.getBlockAllNum() + mapLib.getMapNum() + eventLib.getEventNum()
                + actionLib.getActionNum() + monLib.getMonsterNewID() + animationLib.getAnimationNum()
                + itemLib.getItemNewID() + plotLib.getPlotNum() + tankLib.getNewTankID() + mapAnimationLibrary.getMapAnimationSize()+ fcv.getSaveUploadIsOk())
                / fcv.getGameAlldataNum()));
        g.drawString(fcv.getLoadFileNum() + "%", (int) (fcrMaster.getWidth() / 2 - 18 * fcv.getProportion()),
                (int) (fcrMaster.getHeight() / 2 + 70 * fcv.getProportion()));
        if (fcv.getLoadFileNum() >= 100) {
            fcv.setInterfacenum(5);
            // 设置进入后播放的音乐
            if (fcv.getSaveMouseClick() < 0) {
                gamedate.setDate(2345, 5, 20, 13, 14);
                sound.setBackgroundMusic(2);
            } else {
                sound.setBackgroundMusic(eventLib.getMusicNumOfMapName(player1.getMapname()));
            }

            fcrMaster.startUpdataNPCActive();
        }
    }

    @Override
    public void setBounds() {

    }
}
